package kr.hikt.androidcomplete01.ch07;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Bundle;
import android.view.View;

public class DrawPath extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyView(this));
	}
	
	class MyView extends View{
		private Paint pnt;
		private Path path;
		
		public MyView(Context context){
			super(context);
			pnt = new Paint();
			path = new Path();
		}

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			canvas.drawColor(Color.LTGRAY);
			
			pnt.setStrokeWidth(5);
			pnt.setColor(Color.RED);
			pnt.setStyle(Paint.Style.STROKE);
			
			path.addCircle(50, 50, 40, Path.Direction.CW);
			path.addRect(100, 10, 150, 90, Path.Direction.CW);
			canvas.drawPath(path, pnt);
			
			path.reset();
			path.moveTo(10, 110);
			path.lineTo(50, 150);
			path.rLineTo(50, -30);
			path.quadTo(120, 170, 200, 110);
			pnt.setStrokeWidth(3);
			pnt.setColor(Color.BLUE);
			canvas.drawPath(path, pnt);
			
			path.reset();
			path.moveTo(10, 220);
			path.cubicTo(80, 150, 150, 220, 220, 180);
			pnt.setStrokeWidth(2);
			pnt.setColor(Color.BLACK);
			canvas.drawPath(path, pnt);
			
			pnt.setTextSize(20);
			pnt.setStyle(Paint.Style.FILL);
			pnt.setAntiAlias(true);
			canvas.drawTextOnPath("curved Text on Path", path, 0, 0, pnt);
			
		}
	}
}
